<?php

class heroController extends Controller{
    public function herodata(){
        
        $heroModel = new heroModel();
        $heroRows = $heroModel->selectHeroRows();
        $this->assign('heroRows',ceil($heroRows/9));
        $num = 9;
        $page = isset($_GET['page'])?$_GET['page']:0;
        $this->assign('page',$page);
        $page = $page*$num;
        $hero = $heroModel->selectHero($page,$num);
        $this->assign('hero',$hero);
        $this->display('hero.tpl');
    }
    public function addHero(){
        $heroModel = new heroModel();
        $rst = $heroModel->deleteHero($_GET['id']);
        if($rst == true){
            $this->herodata();
        }else{
            $this->herodata();
        }
    }
}